//统一管理所有api接口

import requests from "@/api/request";
//mock模拟发请求
import mockRequest from "@/api/mockRequest";

//三级联动接口 /api/product/getBaseCategoryList  get 无参数
export const resCategoryList=()=>{
    //axios请求访问，返回的是promise对象
    return requests({url:'/product/getBaseCategoryList',method:'get'});
}
//获取search页面的list列表
export const resSearchInfo=(params)=>{
    return requests({url:'/list',method:'post',data:params})
}
//获取detail页面的商品详情信息
export const reqGoodInfo=(skuId)=>{
    return requests({url:`/item/${skuId}`,method:'get'})
}
//添加或更新购物车
export const reqAddOrUpdataCart=(skuId,skuNum)=>{
    return requests({url:`/cart/addToCart/${skuId}/${skuNum}`,method:'post'})
}
//获取购物车商品列表
export const  reqShopCartList=()=>{
    return requests({url:'/cart/cartList',method:'get'})
}
//删除购物车商品
export const reqDeleteCarListById=(skuId)=>{
    return requests({url:`/cart/deleteCart/${skuId}`,method:'delete'})
}
//修改购物车商品的勾选状态
export const reqUpdateCheckedById=(skuId,isChecked)=>{
    return requests({url:`/cart/checkCart/${skuId}/${isChecked}`,method:'get'})
}


//登录与注册
//注册获取验证码
export const reqGetCode=(phone)=>{
    return requests({url:`/user/passport/sendCode/${phone}`,method:'get'})
}
//用户注册
export const reqUserRegister=(data)=>{
    return requests({url:'/user/passport/register',method:'post',data})
}
//用户登录
export const reqUserLogin=(data)=>{
    return requests({url:'/user/passport/login',method:'post',data})
}
//根据token获取用户信息
export const reqUserInfo=()=>{
    return requests({url:'/user/passport/auth/getUserInfo',method:'get'})
}
//用户退出登录
export const reqLogout=()=>{
    return requests({url:'/user/passport/logout',method:'get'})
}

//获取用户地址信息
export const reqUserAddressInfo=()=>{
    return requests({url:'/user/userAddress/auth/findUserAddressList',method:'get'})
}
//获取用户订单信息
export const reqOrderInfo=()=>{
    return requests({url:'/order/auth/trade',method:'get'})
}
//提交订单
export const reqSubmitOrder=(tradeNo,data)=>{
    return requests({url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,method:'post',data})
}
//获取支付订单信息
export const reqPaymentInfo=(orderId)=>{
    return requests({url:`/payment/weixin/createNative/${orderId}`,method:'get'})
}
//获取订单支付状态信息
export const reqPaymentStatus=(orderId)=>{
    return requests({url:`/payment/weixin/queryPayStatus/${orderId}`,method:'get'})
}
//获取全部订单列表信息
export const reqAllPaymentInfo=(page,limit)=>{
    return requests({url:`/order/auth/${page}/${limit}`,method:'get'})
}





//mock
//mock 请求访问轮播图banner接口
export const resBannerList=()=>{
    return mockRequest({url:'/banner',method:'get'})
}

//mock 请求访问轮播图banner接口
export const resFloorList=()=>{
    return mockRequest({url:'/floor',method:'get'})
}
